<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        table tr th,td{
            border: 1px solid black;
            text-align: center;
        }
        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
        a{
            cursor: pointer;
        }
        input{
             border-top: none;
             border-left: none;
             border-right: none;
             border-bottom: black solid 1px;
         }


    </style>
    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/bootstrap.css">

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap-table1.15.3.js"></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/bootstrap-min-4.3.1.js"></script>
    <script src="../js/pintuer.js"></script>
    <script src="../js/initMain.js"></script>
    <script type="text/javascript">
        function initTable(){
            $("#tableInfo").bootstrapTable({
                method:"post",
                contentType:"application/json",
                url:"/mManufacture/queryAllMManufacture.action",
                //设置交替行样式
                striped:true,
                //初始显示页数
                pageNum:1,
                //是否显示分页
                pagination:true,
                //设置是服务端分页还是客户端分页
                sidePagination:"server",
                //页大小
                pageSize:3,
                //分页列表
                pageList: [3,5,6,10],
                //上传到服务器的参数
                queryParams:function (data) {
                    return{
                        //计算页号，当前号
                        pageNum:(data.offset/data.limit)+1,
                        //计算页大小
                        pageSize: data.limit,
                    }
                },
                columns:[

                    {title:"派工单编号",field:"manufactureId",align:"center",formatter:function (value,row,index) {
                            return "<a href='#' onclick='queryMManufactureById("+JSON.stringify(row)+")'>"+value+"</a>"
                        }},
                    {title:"产品编号",field:"productId",align:"center"},
                    {title:"产品名称",field:"productName",align:"center"},
                    {title:"投产数量",field:"amount",align:"center"},
                    {title:"合格数量",field:"testedAmount",align:"center",formatter:function (value,row,index) {
                            if(value==""||value=="null"){
                                return "生产中";
                            }
                        }},
                    {title:"审核状态",field:"checkTag",align:"center",formatter:function (value,row,index) {
                            if (value == 'S001-2') {
                                var span = '<span style="color: red">审核不通过</span>';
                                return span;
                            } else if (value == 'S001-1') {
                                var span = '<span style="color: green">审核通过</span>';
                                return span;
                            } else if (value == 'S001-0') {
                                var span = '<span style="color: black">等待审核</span>';
                                return span;
                            }
                    }}
                ]

            })
        }
        $(function () {
            initTable();

        })
        var productId;
        function init() {
            $("#MDesignProcedureDetailsTable").bootstrapTable({
                method:"post",
                contentType:"application/json",
                url:"/mProcedure/queryMProcedureByPId.action",
                //设置交替行样式
                striped:true,
                //初始显示页数
                pageNum:1,
                //是否显示分页
                pagination:true,
                //设置是服务端分页还是客户端分页
                sidePagination:"server",
                //页大小
                pageSize:3,
                //分页列表
                pageList: [3,5,6,10],
                //上传到服务器的参数
                queryParams:function (data) {
                    return{
                        //计算页号，当前号
                        pageNum:(data.offset/data.limit)+1,
                        //计算页大小
                        pageSize: data.limit,

                        mManufactureId:mManufactureObj.id
                    }
                },

                columns:[

                    {title:"序号",field:"detailsNumber",align:"center"},
                    {title:"工序名称",field:"procedureName",align:"center"},
                    {title:"工序编号",field:"procedureId",align:"center"},
                    {title:"工时数(小时)",field:"labourHourAmount",align:"center"},
                    {title:"单位工时成本",field:"costPrice",align:"center"},
                    {title:"工时成本小计(元)",field:"subtotal",align:"center"},
                    {title:"物料成本小计(元)",field:"moduleSubtotal",align:"center"},
                    {title:"审核物料",field:"id",align:"center",formatter:function (value,row,index) {
                            return "<a href='#' onclick='queryModule("+JSON.stringify(row)+")'>审核物料</a>"
                        }},
                ]
            })
        }
        //点击审核时
        var MDesignProcedureDetailsId;
        var mManufactureObj;
        function queryMManufactureById(mManufacture) {
            mManufactureObj=mManufacture;
            productId=mManufacture.productId;
            // alert(mManufacture.id);
            $.ajax({
                url: "/mManufacture/queryMDesignProcedureById.action",
                data:"mManufactureId="+mManufacture.id,
                type:"post",
                success:function (data) {
                    // $("#")a;
                    $("#addModel").modal("show");
                    $("#manufactureId").text(data.manufactureId);
                    $("#productId").text(data.productId);
                    $("#productName").text(data.productName);
                    $("#amount").text(data.amount);
                    $("#designer").text(data.designer);
                    $("#labourCostPriceSum").text(data.labourCostPriceSum);
                    $("#moduleCostPriceSum").text(data.moduleCostPriceSum);
                    $("#register").text(data.register);
                    $("#registerTime").text(data.registerTime);
                    $("#checker").text(data.checker);
                    $("#checkTime").text(data.checkTime);
                    $("#remark").text(data.remark);
                    $("#MDesignProcedureDetailsTable").bootstrapTable('destroy');
                    init();
                }
            })
        }
        //点击查看物料时
        var MProcedureId;
        function queryModule(mProcedure) {
            MProcedureId=mProcedure.id;
            // alert(MDesignProcedureDetails.id);
            $("#addDesignModel").modal("show");
            $("#MDesignModuleTable").bootstrapTable('destroy');
            initMDesignModule();
            $("#procedureId").text(mProcedure.procedureId);
            $("#procedureName").text(mProcedure.procedureName);
            $("#moduleSubtotal").text(mProcedure.moduleSubtotal);

        }
        function initMDesignModule() {
            $("#MDesignModuleTable").bootstrapTable({
                method:"post",
                contentType:"application/json",
                url:"/mProcedureModule/queryMProcedureModuleByPId.action",
                //设置交替行样式
                striped:true,
                //初始显示页数
                pageNum:1,
                //是否显示分页
                pagination:true,
                //设置是服务端分页还是客户端分页
                sidePagination:"server",
                //页大小
                pageSize:3,
                //分页列表
                pageList: [3,5,6,10],
                //上传到服务器的参数
                queryParams:function (data) {
                    return{
                        //计算页号，当前号
                        pageNum:(data.offset/data.limit)+1,
                        //计算页大小
                        pageSize: data.limit,

                        pId:MProcedureId
                    }
                },

                columns:[

                    {title:"序号",field:"detailsNumber",align:"center"},
                    {title:"物料名称",field:"productName",align:"center"},
                    {title:"物料编号",field:"productId",align:"center"},
                    {title:"本工序数量",field:"amount",align:"center"},
                    {title:"单价",field:"costPrice",align:"center"},
                    {title:"小计",field:"subtotal",align:"center"},
                ]
            })
        }
    </script>
</head>
<body>
    <div>

        <table id="tableInfo">

        </table>
    </div>
    <div class="modal  fade" id="addModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 90%">
            <div class="modal-content" style="border: 1px solid black;">
                <div class="modal-header">
                    <div class="container">
                        <div class="row">
                            <div class="col-7" style="text-align: right">
                                <h5 class="modal-title" id="info" >
                                    生产派工单
                                </h5>
                            </div>
                            <div class="col-2"></div>
                            <div class="col-3" style="position: absolute;right: 30px">
                            </div>
                        </div>
                    </div>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right: 0px">

                    </button>
                </div>
                <div class="modal-body">
                    <form id="addProcedureForm">
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-2" style="text-align: right">
                                    <span>派工单编号：</span>
                                </div>
                                <div class="col-4">
                                    <span id="manufactureId"></span><br>
                                </div>

                            </div>
                        </div><br>

                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    产品名称：
                                </div>
                                <div class="col-4">
                                    <span id="productName">笔记本</span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    产品编号：
                                </div>
                                <div class="col-4">
                                    <span id="productId" >20001002192001</span>
                                </div>
                            </div>
                        </div><br>
                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    数量：
                                </div>
                                <div class="col-4">
                                    <span id="amount"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    工单制定人：
                                </div>
                                <div class="col-4">
                                    <span id="designer"></span>
                                </div>
                            </div>
                        </div><br>


                        <table id="MDesignProcedureDetailsTable"  style="margin-left: 20px">

                        </table><br>
                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    工时总成本：
                                </div>
                                <div class="col-4">
                                    <span name="labourCostPriceSum" id="labourCostPriceSum"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    物料总成本：
                                </div>
                                <div class="col-4">
                                    <span  name="moduleCostPriceSum" id="moduleCostPriceSum"></span>
                                </div>
                            </div>
                        </div><br>

                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    登记人：
                                </div>
                                <div class="col-4">
                                    <span name="register" id="register"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    登记时间：
                                </div>
                                <div class="col-4">
                                    <span  name="registerTime" id="registerTime"></span>
                                </div>
                            </div>
                        </div><br>
                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    审核人：
                                </div>
                                <div class="col-4">
                                    <span name="checker" id="checker"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    审核时间：
                                </div>
                                <div class="col-4">
                                    <span  name="checkTime" id="checkTime"></span>
                                </div>
                            </div>
                        </div><br>
                        <span style="margin-left: 55px">备注：</span>
                        <span  id="remark">

                        </span>

                    </form>
                </div>

            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>


<!--    设计工序物料-->
    <div class="modal  fade" id="addDesignModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 90%;height: 500px">
            <div class="modal-content" style="border: 1px solid black;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right: 0px">

                    </button>
                </div>
                <div style="width: 80%;height: 400px;border: 2px solid gray;margin: 0 auto;margin-top: 10px">
                    <h3 align="center" style="margin-top: 30px">工序物料单</h3>
                    <div class="container-fluid">
                        <form id="putRegister">
                            <div class="row" style="margin-top: 30px;">
                                <div class="col-3" style="text-align:right">
                                    设计单编号：
                                </div>
                                <div class="col-4">
                                    <span id="procedureId"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    工序名称：
                                </div>
                                <div class="col-3">
                                    <span id="procedureName"></span>
                                </div>

                            </div>
                            <div class="row" style="margin-top: 30px;">
                                <div class="col-3" style="text-align:right">
                                    物料总成本：
                                </div>
                                <div class="col-4">
                                    <span id="moduleSubtotal"></span>
                                </div>

                            </div>

                            <div>
                                <table id="MDesignModuleTable" width="80%" style="margin-top: 20px;" class="table table-sm">

                                </table>
                            </div>


                        </form>
                    </div>
                </div>

            </div>
        </div>
    </div>
</body>

</html>